🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / ui / src / commonMain / kotlin / org / meshtastic / core / ui / viewmodel / ViewModelExtensions.kt
Displaying Raw • Download
core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/viewmodel/ViewModelExtensions.kt 520fa717a938fd84682403b41f57d9f7e1ef49ef (520fa717) Text, 1.73 KB
T8b949e/*
* Copyright (c) 2025-2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tf0883e@fileTb4b4b4:Te6edf3SuppressTb4b4b4(Ta5d6ff"Ta5d6ffWrappingTa5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ffUnusedImportsTa5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ffSpacingAroundColonTa5d6ff"Tb4b4b4)
Tff7b72package T7ee787org.meshtastic.core.ui.viewmodel
Tff7b72import T7ee787androidx.lifecycle.ViewModel
Tff7b72import T7ee787androidx.lifecycle.viewModelScope
Tff7b72import T7ee787kotlinx.coroutines.flow.Flow
Tff7b72import T7ee787kotlinx.coroutines.flow.SharingStarted
Tff7b72import T7ee787kotlinx.coroutines.flow.StateFlow
Tff7b72import T7ee787kotlinx.coroutines.flow.stateIn
Tff7b72import T7ee787kotlin.time.Duration
Tff7b72import T7ee787kotlin.time.Duration.Companion.seconds
T8b949e/**
* Extension for converting a [Flow] to a [StateFlow] in a [ViewModel] context.
*
* @param initialValue the initial value of the state flow
* @param stopTimeout configures a delay between the disappearance of the last subscriber and the stopping of the
* sharing coroutine.
*/
Te6edf3contextTb4b4b4(Te6edf3viewModelTb4b4b4: Te6edf3ViewModelTb4b4b4)
Tff7b72fun Tff7b72<Te6edf3TTff7b72> Td2a8ffFlowTff7b72<Te6edf3TTff7b72>Tb4b4b4.Te6edf3stateInWhileSubscribedTb4b4b4(Te6edf3initialValueTb4b4b4: Te6edf3TTb4b4b4, Te6edf3stopTimeoutTb4b4b4: Te6edf3Duration Tff7b72= T79c0ff5.Te6edf3secondsTb4b4b4)Tb4b4b4: Te6edf3StateFlowTff7b72<Te6edf3TTff7b72> Tff7b72= Te6edf3stateInTb4b4b4(
Te6edf3scope Tff7b72= Te6edf3viewModelTb4b4b4.Te6edf3viewModelScopeTb4b4b4,
Te6edf3started Tff7b72= Te6edf3SharingStartedTb4b4b4.Te6edf3WhileSubscribedTb4b4b4(Te6edf3stopTimeoutMillis Tff7b72= Te6edf3stopTimeoutTb4b4b4.Te6edf3inWholeMillisecondsTb4b4b4)Tb4b4b4,
Te6edf3initialValue Tff7b72= Te6edf3initialValueTb4b4b4,
Tb4b4b4)
Served by rngit 1.5.0 - Generated in 0.04s